* ==============================================================================
* ==============================================================================
* Title: The impact of IMF conditionality on government health expenditure: A cross-national analysis of 16 West African nations
* Authors: Thomas Stubbs, Alexander Kentikelenis, David Stuckler, Martin McKee, Lawrence King
* Version: Final (24 January 2017)
* ==============================================================================
* ==============================================================================

cd "D:\Dropbox\Projects\- Completed\IMFWAHS\"
* Change location to directory where files were unzipped

* ==============================================================================
* Generate variables
* ==============================================================================
xtset cid year
rename hxp_pub_gdp_WDI hgdp_wdi
rename pop_urb_grow_WDI urban
rename depratio_tot_WDI dratio
rename fh_ipolity2_QOG fhip
rename war_UCDP war
rename gdp_growth_WDI growth
rename ggr_ngdp_WEO govrev
rename ggx_ngdp_WEO govexp
rename bca_ngdpd_WEO cab
rename oda_WDI oda
gen lngdppc = ln(gdppc_WDI)
gen hrpop1_wdi = (hgdp_wdi/100)* gdppc_WDI
gen hlnrpop1_wdi = ln((hgdp_wdi/100)* gdppc_WDI)
egen IMFother = sum(IMF6n) if year>=1985 & year<2014, by(year)
gen ln_oda = ln(oda_pc_WDI)

* ==============================================================================
* Table 2. Effect of IMF conditionality on government health spending, 1995-2012
* ==============================================================================
xtset cid year
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hlnrpop1_wdi l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard
test L.IMF6n L.BA2TOT
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
esttab, b(3) ci nogaps nostar brackets scalars(r2 N_clust) sfmt(a4) drop(*cid *year) wide
esttab, b(4) p(5) nogaps nostar brackets scalars(r2 N_clust) sfmt(a4) drop(*cid *year) wide
eststo clear

* ==============================================================================
* Figure 2.  Joint effect of IMF programme participation and conditionality on government health spending per capita, with 95% confidence intervals
* ==============================================================================
xtset cid year
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
margins, at(l.BA2TOT=(0 10 20 30 40 50 60 70 80) l.IMF6n=1) at(l.BA2TOT=0 l.IMF6n=0) vsquish
marginsplot
* manual edits to style
graph export Figures\IMFWAHS_Figure2.png, replace width(4000)
drop hazard
eststo clear

* ==============================================================================
* Factual sentences
* ==============================================================================
* "...totalling 8344 (4886 binding and 3458 non-binding) across the 16 countries."
gen BINDING = BA2TOT
gen NONBINDING = BA1TOT - BA2TOT
table cname if year>=1995 & year<=2014, c(sum BA1TOT sum BINDING sum NONBINDING) row
drop BINDING NONBINDING
* "The mean number of binding conditions when countries participate in IMF programmes, at 25 per year..."
tabstat BA2TOT if year>=1994 & year<=2011 & BA2TOT!=0, s(n mean median sd mi ma) col(s)
* "Setting government health spending per capita at the mean value of our entire sampled$--14.66 constant 2005 US dollars..."
gen hrpop3_wdi = (hgdp_wdi/100)* gdppc_WDI
tabstat hrpop3_wdi if year>=1995 & year<=2012, s(n mean median sd mi ma) col(s)
* "...these “priority spending floors” can contribute to increases in budgetary allocations for health (IMF, 2015a), as in the case of Gambia in 2012"
list cname year hrpop1_wdi hgdp_wdi if cname=="Gambia, The"
* "Im-Pesaran-Shin tests on the dependent variable reject the null hypothesis that the panels contain a unit root, whether demeaned, with a time trend, or both..."
xtunitroot ips hlnrpop1_wdi if year>=1995 & year<=2012, demean
xtunitroot ips hlnrpop1_wdi if year>=1995 & year<=2012, trend
xtunitroot ips hlnrpop1_wdi if year>=1995 & year<=2012, trend demean
* "The Sargan test for overidentification is non-significant, indicating instruments are valid."
qui: ivregress 2sls hlnrpop1_wdi l.lngdppc dratio urban war l.ln_oda i.cid (l.BA2TOT l.IMF6n = l.dy_unga3USA l.IMFother l2.fhip) if year>=1995 & year<=2012, vce(robust) first small
estat overid

* ==============================================================================
* Appendix 3. Descriptive statistics
* ==============================================================================
tabstat hlnrpop1_wdi if year>=1995 & year<=2012, s(n mean median sd mi ma) col(s)
tabstat BA2TOT IMF6n lngdppc ln_oda if year>=1994 & year<=2011, s(n mean median sd mi ma) col(s)
tabstat BA2TOT if year>=1994 & year<=2011 & IMF6n==1, s(n mean median sd mi ma) col(s)
tabstat dratio urban war if year>=1995 & year<=2012, s(n mean median sd mi ma) col(s)
tabstat IMFother2 if year>=1995 & year<=2012, s(n mean median sd mi ma) col(s)
tabstat growth cab fhip if year>=1994 & year<=2011, s(n mean median sd mi ma) col(s)

* ==============================================================================
* Appendix 4. Correlation matrix
* ==============================================================================
xtset cid year
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
qui: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard
pwcorr hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc l.ln_oda dratio urban war if e(sample)

* ==============================================================================
* Appendix 5. Controlling for selection bias using the Heckman method
* ==============================================================================
xtset cid year
eststo: probit IMF6n IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda if year>=1995 & year<=2012 & !missing(hlnrpop1_wdi) & !missing(l.BA2TOT)
predict fundtemp if e(sample)
replace fundtemp = 1 if fundtemp>.5 & !missing(fundtemp)
replace fundtemp = 0 if fundtemp<.5 & !missing(fundtemp)
tab IMF6n fundtemp
drop fundtemp
esttab, b(3) se(3) pr2 nogaps brackets star (* 0.10 ** 0.05 *** 0.01)
eststo clear 

* ==============================================================================
* Appendix 6. Robustness checks
* ==============================================================================
xtset cid year
* Base Heckman for Log government health expenditure per capita
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
eststo clear
drop hazard
* 2SLS for Log government health expenditure per capita		
eststo: reg3 (l.BA2TOT l.IMF6n = l2.lngdppc l.dratio l.urban l.war l2.ln_oda l2.fhip l.dy_unga3USA l.IMFother2 i.cid ) (hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year) if year>=1995 & year<=2012, 2sls
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2_3 N_clust) sfmt(a4) drop(*cid *year)
eststo clear
* Heckman for Government health expenditure (% of GDP)
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hgdp_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hgdp_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
drop hazard
eststo clear
* No Outliers (observations with >=50 conditions) for Log government health expenditure per capita
gen leveraged = l.BA2TOT>=50
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012 & !leveraged, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012 & !leveraged, cluster(cid)
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
eststo clear
drop hazard
drop leveraged
* No Outliers (observations with >=40 conditions) for Log government health expenditure per capita
gen leveraged = l.BA2TOT>=40
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012 & !leveraged, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012 & !leveraged, cluster(cid)
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
eststo clear
drop hazard
drop leveraged

* ==============================================================================
* Table R1. Determinants of government health spending, 1995-2012 [Condition classifications]
* ==============================================================================
* Table included in response to reviewers
xtset cid year
gen BA1POVdum = BA1POV >0 & !missing(BA1POV)
gen BA1LABdum = BA1LAB >0 & !missing(BA1LAB)
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
*BA1POV	
qui: etreg hlnrpop1_wdi l.BA1POV l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA1POV l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard
*BA1LAB	
qui: etreg hlnrpop1_wdi l.BA1LAB l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA1LAB l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard		
*BA1POVdum
qui: etreg hlnrpop1_wdi l.BA1POVdum l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA1POVdum l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard	
*BA1LABdum
qui: etreg hlnrpop1_wdi l.BA1LABdum l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA1LABdum l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard			
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
eststo clear

* ==============================================================================
* Table R3. Determinants of government health spending, 1995-2012 [War lag]
* ==============================================================================
* Table included in response to reviewers
xtset cid year
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban l.war l.ln_oda"
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban l.war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban l.war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
drop hazard
esttab, b(4) se(4) nogaps brackets star (* 0.05 ** 0.01 *** 0.001) scalars(r2 N_clust) sfmt(a4) drop(*cid *year)
eststo clear

* ==============================================================================
* Figure R1. Residual-Versus-Fitted Plot of Base Model
* ==============================================================================
* Figure included in response to reviewers
xtset cid year
local select "IMFother2 l.growth l.cab l.fhip l.lngdppc dratio urban war l.ln_oda"
qui: etreg hlnrpop1_wdi l.BA2TOT l.lngdppc dratio urban war l.ln_oda i.cid i.year if year>=1995 & year<=2012, treat(IMF6n = `select') twostep hazard(hazard)
eststo: reg hlnrpop1_wdi l.IMF6n l.BA2TOT l.lngdppc dratio urban war l.ln_oda hazard i.cid i.year if year>=1995 & year<=2012, cluster(cid)
rvfplot, yline(0)
* manual edits to style
graph export Figures\IMFWAHS_FigureR1.png, replace width(4000)

* ==============================================================================
* ==============================================================================
